<?php
/*require_once('mysql.php');
require_once('ErrorCode.php');
class Content{
	private $db;
	private $uid;
	public function __construct(){
		$this->db = new Database('localhost','root','168168','phpwamp');
		$this->uid = 2;

		$this->db->select_table('contents');

	}
	//创建
	public function add($data){
		$data = $this->_checkData($data);
		if($data){
			$rs = $this->db->data($data)->add();
			if($rs){
				echo "发布成功";
			}
		}
		
	}
	//修改
	public function edit($uid,$data){
		$data = $this->_checkData($data);
		if($data){
			$rs = $this->db->where("aid = '{$uid}'")->save($data);
			if($rs){
				echo "修改成功";
			}else{
				echo "修改失败";
			}
		}
	}
	//删除
	public function del($id){
		$rs = $this->db->where("userid = '{$this->uid}' and aid = ".$id)->delete();
		if($rs){
			echo "删除成功";
		}else{
			echo "删除失败";
		}
	}
	//读取文章列表
	public function getList($uid,$page=1,$size=2){
		$where = array('userid' => 2);
		$limit = ($page-1)*$size ;
		$limit = $limit < 0 ?0:$limit;
	$rs = $this->db->where('userid = 2')->limit(3,3)->find();

		var_dump($rs);
	}

	//简单过滤
	private function _checkData($data){
		$newData = array();
		foreach ($data as $key => $value) {
			if(empty($value)){
				echo "字段：".$key." 不能为空";
				return false;
			}else{
				$newData[$key] = $value;
			}
		}
		return $newData;
	}
}*/